<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ question.question_text }} - 投票结果</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            margin: 0;
            padding: 0;
        }

       .container {
            max-width: 600px;
            margin: 50px auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 20px;
        }

        ul {
            list-style-type: none;
            padding: 0;
        }

        li {
            margin-bottom: 15px;
        }

       .vote-bar-container {
            background-color: #f0f0f0;
            border-radius: 5px;
            overflow: hidden;
        }

       .vote-bar {
            background-color: #007BFF;
            color: #fff;
            text-align: center;
            padding: 5px;
            border-radius: 5px;
            transition: width 0.3s ease;
            height: 20px; /* 设置固定高度 */
        }

       .vote-percentage {
            margin-left: 10px;
            font-weight: bold;
            color: #333;
        }

       .action-buttons {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }

       .action-buttons a {
            display: inline-block;
            padding: 10px 20px;
            background-color: #007BFF;
            color: #fff;
            text-decoration: none;
            border-radius: 5px;
            margin: 0 5px;
        }

       .action-buttons a:hover {
            background-color: #0056b3;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>{{ question.question_text }}</h1>
        <ul>
            {% if question.choice_set.all %}
                {% for choice in question.choice_set.all %}
                    <li>
                        <span>{{ choice.choice_text }}</span>
                        <div class="vote-bar-container">
                            <div class="vote-bar" style="width: {% widthratio choice.votes total_votes 100 %}%">
                                {{ choice.votes }} 票
                            </div>
                        </div>
                        <span class="vote-percentage">{% widthratio choice.votes total_votes 100 %}%</span>
                    </li>
                {% endfor %}
            {% endif %}
        </ul>
        <div class="action-buttons">
            <a href="{% url 'polls:detail' question.id %}">再次投票？</a>
            <a href="{% url 'polls:index' %}">回到投票首页</a>
        </div>
    </div>
</body>

</html>